package app;

import model.*;

public class Main {
    public static void main(String[] args) {
        Product[] pros = {
            new Electronics("E01", "iPhone15", 6999, "Apple"),
            new Electronics("E02", "Mate60", 5999, "Huawei"),
            new Clothing("C01", "牛仔裤", 299, "L"),
            new Clothing("C02", "卫衣", 199, "XL"),
            new Book("B01", "Java核心技术", 128, "9787111234567"),
            new Book("B02", "c语言", 99, "9787121345678"),
            new Food("F01", "进口牛奶", 29, "2026-12-01"),
            new Food("F02", "坚果礼盒", 89, "2026-10-01"),
            new Cosmetics("M01", "兰蔻面霜", 520, "干性"),
            new Cosmetics("M02", "雅诗兰黛精华", 880, "混合性")
        };

        for (Product p : pros) {
            System.out.println(p.getDescription());
            // 调用特有方法
            if (p instanceof Electronics) ((Electronics) p).showSpecs();
            if (p instanceof Clothing)    ((Clothing) p).tryOn();
            if (p instanceof Book)        ((Book) p).open();
            if (p instanceof Food)        ((Food) p).eat();
            if (p instanceof Cosmetics)   ((Cosmetics) p).apply();
            System.out.println();
        }
    }
}